package guij.controller;

import guij.dao.mapper.ItemMapper;
import guij.taobao.TaobaokeInterface;
import guij.taobao.TopInterface;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.taobao.api.model.Item;

// 添加一个商品到rss 服务器
public class AddRSSItem implements Controller {

	public ModelAndView handleRequest(HttpServletRequest arg0,
			HttpServletResponse arg1) throws Exception {
		String Num_iid = arg0.getParameter("Num_iid");
		Item item = topInterface.getItem(Num_iid);
		String scilckurl = taobaokeInterface.GetTaobaokeItemURL(Num_iid);
		if (scilckurl != null) {
			item.setDetailUrl(scilckurl);
		}
		itemMapper.insert(item);
		return new ModelAndView();
	}

	public void setTopInterface(TopInterface topInterface) {
		this.topInterface = topInterface;
	}

	public TopInterface getTopInterface() {
		return topInterface;
	}

	public void setTaobaokeInterface(TaobaokeInterface taobaokeInterface) {
		this.taobaokeInterface = taobaokeInterface;
	}

	public TaobaokeInterface getTaobaokeInterface() {
		return taobaokeInterface;
	}

	public void setItemMapper(ItemMapper itemMapper) {
		this.itemMapper = itemMapper;
	}

	public ItemMapper getItemMapper() {
		return itemMapper;
	}

	private TopInterface topInterface;
	private TaobaokeInterface taobaokeInterface;
	private ItemMapper itemMapper;
	public void setViewPage(String viewPage) {
			this.viewPage = viewPage;
		}
	
		public String getViewPage() {
			return viewPage;
		}
	
		private String viewPage;
}
